package com.matt.foundation.constant;

import com.google.common.collect.ImmutableMap;
import lombok.Setter;
import org.assertj.core.util.Lists;
import java.util.List;

/**
 * @Describle This Class Is 模板类型
 * @Author ZengMin
 * @Date 2018/12/19 14:24
 * @Company Matt
 */
public class TeachingTempleteConstant {

    //定义一些模板常量
    public static final int TEMPLETE_TYPE_ALL = 0;  //全部模块类型
    public static final int TEMPLETE_TYPE_PAD = 1;  //PAD模块
    public static final int TEMPLETE_TYPE_COURSE = 2;//课程模块
    public static final int TEMPLETE_TYPE_COMMON_CHILD = 3;  //通用子类型
    public static final int TEMPLETE_TYPE_FLOW_CHILD = 4;  //流程子类型
    public static final int TEACHING_ADD = 1;   //新增
    public static final int TEACHING_UPDATE = 2;   //更新
    public static final int COURSE_GENERAL = 3; //基本
    //定义一些课程扩展信息字段常量
    public static final String COURSEDETAIL_TYPE = "type";  //类型
    public static final String COURSEDETAIL_TYPECODE = "typeCode";  //类型code
    public static final String COURSEDETAIL_NAME = "name";  //名称

    public enum MODULE {
        PAD(1, "PAD模块"),
        COURSE(2, "课程模块"),
        COMMON_CHILD(3, "通用子类型"),
        FLOW_CHILD(4, "流程子类型");

        @Setter
        private int code;

        @Setter
        private String value;

        MODULE(int code, String value) {
            this.code = code;
            this.value = value;
        }
        public static List getAll() {
            List list = Lists.newArrayList();
            for (MODULE p : MODULE.values()) {
                list.add(ImmutableMap.of("value", p.code, "value", p.value));
            }
            return list;
        }
        public static String getValue(int code) {
            for (MODULE p : MODULE.values()) {
                if (p.code == code) {
                    return p.value;
                }
            }
            return null;
        }
    }


    public enum PAD {
        GENERAL(1, "普通"),
        H5(2, "H5"),
        FILE(3, "附件"),
        POINT(4, "观测点"),
        FEED(5, "动态");

        @Setter
        private int code;

        @Setter
        private String value;

        PAD(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public static String getValue(int code) {
            for (PAD p : PAD.values()) {
                if (p.code == code) {
                    return p.value;
                }
            }
            return null;
        }

        public static int getCode(String value) {
            for (PAD p : PAD.values()) {
                if (p.value.equals(value)) {
                    return p.code;
                }
            }
            return 0;
        }

        public static List getAll() {
            List list = Lists.newArrayList();
            for (PAD p : PAD.values()) {
                list.add(ImmutableMap.of("value", p.code, "value", p.value));
            }
            return list;
        }

    }

    public enum COURSE {
        COMMON(1, "通用"),
        H5(2, "H5"),
        GENERAL(3, "基本"),
        TEACHTOOL(4, "教具"),
        FLOWSINGLE(51, "单一流程"),
        FLOWMULTI(52, "复合流程"),
        POINT(6, "观测点"),
        FILE(7, "附件"),
        VIDEO(8, "教学视频");

        @Setter
        private int code;

        @Setter
        private String value;

        COURSE(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public static String getValue(int code) {
            for (COURSE p : COURSE.values()) {
                if (p.code == code) {
                    return p.value;
                }
            }
            return null;
        }

        public static int getCode(String value) {
            for (COURSE p : COURSE.values()) {
                if (p.value.equals(value)) {
                    return p.code;
                }
            }
            return 0;
        }

        public static List getAll() {
            List list = Lists.newArrayList();
            for (COURSE p : COURSE.values()) {
                list.add(ImmutableMap.of("value", p.code, "value", p.value));
            }
            return list;
        }

    }

    public enum COURSE_COMMON {
        TEXT(1, "纯文本"),
        RICHTEXT(2, "富文本"),
        IMAGE(3, "图片"),
        RADIO(4, "单选"),
        CHECKBOX(5, "多选"),
        NUMBER(6, "数字");

        @Setter
        private int code;

        @Setter
        private String value;

        COURSE_COMMON(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public static String getValue(int code) {
            for (COURSE_COMMON p : COURSE_COMMON.values()) {
                if (p.code == code) {
                    return p.value;
                }
            }
            return null;
        }

        public static int getCode(String value) {
            for (COURSE_COMMON p : COURSE_COMMON.values()) {
                if (p.value.equals(value)) {
                    return p.code;
                }
            }
            return 0;
        }

        public static List getAll() {
            List list = Lists.newArrayList();
            for (COURSE_COMMON p : COURSE_COMMON.values()) {
                list.add(ImmutableMap.of("value", p.code, "value", p.value));
            }
            return list;
        }

    }

    public enum COURSE_FLOW {
        TEXT(1, "纯文本"),
        RICHTEXT(2, "富文本"),
        IMAGE(3, "图片"),
        RADIO(4, "单选"),
        CHECKBOX(5, "多选"),
        NUMBER(6, "数字"),
        TEACHTOOL(7, "教具");

        @Setter
        private int code;

        @Setter
        private String value;

        COURSE_FLOW(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public static String getValue(int code) {
            for (COURSE_FLOW p : COURSE_FLOW.values()) {
                if (p.code == code) {
                    return p.value;
                }
            }
            return null;
        }

        public static int getCode(String value) {
            for (COURSE_FLOW p : COURSE_FLOW.values()) {
                if (p.value.equals(value)) {
                    return p.code;
                }
            }
            return 0;
        }

        public static List getAll() {
            List list = Lists.newArrayList();
            for (COURSE_FLOW p : COURSE_FLOW.values()) {
                list.add(ImmutableMap.of("value", p.code, "value", p.value));
            }
            return list;
        }

    }

}
